package com.bzchao.wechat.controller;

import com.bzchao.wechat.common.dto.Result;
import com.bzchao.wechat.service.WeChatService;
import com.bzchao.wechat.wxopen.dto.response.UserInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/wechat/user")
public class WechatUserController {

    @Autowired
    private WeChatService weChatService;

    /**
     * 根据用户授权code，获得用户信息
     */
    @GetMapping(value = "/userInfo")
    public Result getUserInfo(String code) {
        UserInfo userInfo = weChatService.getUserInfoByAuthCode(code);
        return Result.data(userInfo);
    }

}
